package siga.visao_financeiro;

import java.sql.SQLException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.swing.JOptionPane;
import siga.banco.conexao;
import siga.pacotao.contadorData;
import siga.visao.index;
import siga.visao.verErros;
import siga.visao_busca.buscaVer;
import siga.visao_busca.buscaTurma;
import siga.visao_busca.buscaPlanoContas;
import siga.visao_busca.buscaCentroCusto;

/**
 *
 * @author rafaelfrasson
 */
public class movCaixaGerar extends javax.swing.JDialog {
    static String cod_plano_contas="";
    static String cod_centro_custo="";
    static String cod_turma="";
    static String cod_fase="";
    static String cod_pessoa="";
    
    public static boolean ConfirmaGerar;
    public static boolean isConfirmaGerar() {
        return ConfirmaGerar;
    }
    public static void setConfirmaGerar(boolean ConfirmaGerar) {
        movCaixaGerar.ConfirmaGerar = ConfirmaGerar;
    }

    public movCaixaGerar(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jpCGPrincipal = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jtfPessoa = new javax.swing.JTextField();
        jbBuscaPessoa = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jtfTurma = new javax.swing.JTextField();
        jbBuscaTurma = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jtfParIni = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jtfParcFim = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jtfPlanoContas = new javax.swing.JTextField();
        jbPlanoContas = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jtfCentroCusto = new javax.swing.JTextField();
        jbCentroCusto = new javax.swing.JButton();
        jLabel7 = new javax.swing.JLabel();
        jtfHistorico = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jtfVlBruto = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jtfReceber = new javax.swing.JCheckBox();
        jLabel10 = new javax.swing.JLabel();
        jtfVlRecebido = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        jtfDataRecebido = new javax.swing.JFormattedTextField();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jtfDataVenc = new javax.swing.JFormattedTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Gerar Menssalidades");
        setIconImage(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/gerar_men_16x16.png")).getImage());
        setModal(true);
        setResizable(false);
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosed(java.awt.event.WindowEvent evt) {
                formWindowClosed(evt);
            }
            public void windowOpened(java.awt.event.WindowEvent evt) {
                formWindowOpened(evt);
            }
        });

        jpCGPrincipal.setName("jpCGPrincipal"); // NOI18N

        jLabel1.setText("Pessoa:");
        jLabel1.setName("jLabel1"); // NOI18N

        jtfPessoa.setEditable(false);
        jtfPessoa.setName("jtfPessoa"); // NOI18N

        jbBuscaPessoa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbBuscaPessoa.setName("jbBuscaPessoa"); // NOI18N
        jbBuscaPessoa.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscaPessoaActionPerformed(evt);
            }
        });

        jLabel2.setText("Turma:");
        jLabel2.setName("jLabel2"); // NOI18N

        jtfTurma.setEditable(false);
        jtfTurma.setName("jtfTurma"); // NOI18N

        jbBuscaTurma.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbBuscaTurma.setName("jbBuscaTurma"); // NOI18N
        jbBuscaTurma.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbBuscaTurmaActionPerformed(evt);
            }
        });

        jLabel3.setText("Parcela(s):");
        jLabel3.setName("jLabel3"); // NOI18N

        jtfParIni.setText("1");
        jtfParIni.setName("jtfParIni"); // NOI18N

        jLabel4.setText("de");
        jLabel4.setName("jLabel4"); // NOI18N

        jtfParcFim.setText("1");
        jtfParcFim.setName("jtfParcFim"); // NOI18N

        jLabel5.setText("Plano de Contas:");
        jLabel5.setName("jLabel5"); // NOI18N

        jtfPlanoContas.setEditable(false);
        jtfPlanoContas.setName("jtfPlanoContas"); // NOI18N

        jbPlanoContas.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbPlanoContas.setName("jbPlanoContas"); // NOI18N
        jbPlanoContas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbPlanoContasActionPerformed(evt);
            }
        });

        jLabel6.setText("Centro de Custo:");
        jLabel6.setName("jLabel6"); // NOI18N

        jtfCentroCusto.setEditable(false);
        jtfCentroCusto.setName("jtfCentroCusto"); // NOI18N

        jbCentroCusto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/siga/imagem/busca_16x16.png"))); // NOI18N
        jbCentroCusto.setName("jbCentroCusto"); // NOI18N
        jbCentroCusto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jbCentroCustoActionPerformed(evt);
            }
        });

        jLabel7.setText("Histórico:");
        jLabel7.setName("jLabel7"); // NOI18N

        jtfHistorico.setName("jtfHistorico"); // NOI18N

        jLabel8.setText("Valor Bruto:");
        jLabel8.setName("jLabel8"); // NOI18N

        jtfVlBruto.setText("0,00");
        jtfVlBruto.setName("jtfVlBruto"); // NOI18N

        jLabel9.setText("Data do Vencimento (Início):");
        jLabel9.setName("jLabel9"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Receber o Título"));
        jPanel1.setName("jPanel1"); // NOI18N

        jtfReceber.setText("Receber esse Título");
        jtfReceber.setName("jtfReceber"); // NOI18N
        jtfReceber.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfReceberActionPerformed(evt);
            }
        });

        jLabel10.setText("Valor Recebido:");
        jLabel10.setName("jLabel10"); // NOI18N

        jtfVlRecebido.setEditable(false);
        jtfVlRecebido.setText("0,00");
        jtfVlRecebido.setName("jtfVlRecebido"); // NOI18N

        jLabel11.setText("Data do Recebimento:");
        jLabel11.setName("jLabel11"); // NOI18N

        jtfDataRecebido.setEditable(false);
        try {
            jtfDataRecebido.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfDataRecebido.setName("jtfDataRecebido"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jtfReceber)
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfVlRecebido, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addGap(18, 18, 18)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jtfDataRecebido)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(295, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel10)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(jtfVlRecebido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jtfDataRecebido, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(jLabel11)
                            .addGap(26, 26, 26)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jtfReceber)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton5.setText("Cancelar");
        jButton5.setName("jButton5"); // NOI18N
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jButton6.setText("Salvar");
        jButton6.setName("jButton6"); // NOI18N
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        try {
            jtfDataVenc.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.MaskFormatter("##/##/####")));
        } catch (java.text.ParseException ex) {
            ex.printStackTrace();
        }
        jtfDataVenc.setName("jtfDataVenc"); // NOI18N

        javax.swing.GroupLayout jpCGPrincipalLayout = new javax.swing.GroupLayout(jpCGPrincipal);
        jpCGPrincipal.setLayout(jpCGPrincipalLayout);
        jpCGPrincipalLayout.setHorizontalGroup(
            jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                            .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                                    .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel1)
                                        .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                                            .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addComponent(jLabel3)
                                                .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                                                    .addComponent(jtfParIni, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jLabel4)
                                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                                    .addComponent(jtfParcFim, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                            .addGap(18, 18, 18)
                                            .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                                .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                                                    .addGap(1, 1, 1)
                                                    .addComponent(jtfTurma, javax.swing.GroupLayout.DEFAULT_SIZE, 631, Short.MAX_VALUE))
                                                .addComponent(jLabel2)))
                                        .addComponent(jtfPessoa, javax.swing.GroupLayout.DEFAULT_SIZE, 746, Short.MAX_VALUE)
                                        .addComponent(jtfCentroCusto, javax.swing.GroupLayout.DEFAULT_SIZE, 746, Short.MAX_VALUE))
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                        .addComponent(jbBuscaTurma, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jbBuscaPessoa, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addComponent(jbCentroCusto, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)))
                                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addGap(10, 10, 10))
                        .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                            .addComponent(jLabel5)
                            .addContainerGap(677, Short.MAX_VALUE))
                        .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                            .addComponent(jtfPlanoContas, javax.swing.GroupLayout.DEFAULT_SIZE, 744, Short.MAX_VALUE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addComponent(jbPlanoContas, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addContainerGap())
                        .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                            .addComponent(jLabel6)
                            .addContainerGap(675, Short.MAX_VALUE))
                        .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                            .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jtfHistorico, javax.swing.GroupLayout.DEFAULT_SIZE, 783, Short.MAX_VALUE)
                                .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                                    .addComponent(jLabel7)
                                    .addGap(297, 297, 297)))
                            .addContainerGap())
                        .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                            .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jtfVlBruto, javax.swing.GroupLayout.PREFERRED_SIZE, 99, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel8))
                            .addGap(18, 18, 18)
                            .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addComponent(jtfDataVenc)
                                .addComponent(jLabel9))
                            .addContainerGap(482, Short.MAX_VALUE)))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jpCGPrincipalLayout.createSequentialGroup()
                        .addComponent(jButton6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton5)
                        .addContainerGap())))
        );
        jpCGPrincipalLayout.setVerticalGroup(
            jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(11, 11, 11)
                        .addComponent(jtfPessoa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jbBuscaPessoa))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfParIni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)
                            .addComponent(jtfParcFim, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jtfTurma, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jbBuscaTurma))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel5)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jtfPlanoContas, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jbPlanoContas, javax.swing.GroupLayout.Alignment.TRAILING))
                .addGap(10, 10, 10)
                .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addGap(11, 11, 11)
                        .addComponent(jtfCentroCusto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jbCentroCusto))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jtfHistorico, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13)
                .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jtfVlBruto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfDataVenc, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(jpCGPrincipalLayout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addGap(26, 26, 26)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(13, 13, 13)
                .addGroup(jpCGPrincipalLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton5)
                    .addComponent(jButton6))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpCGPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jpCGPrincipal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        dispose();
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jtfReceberActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfReceberActionPerformed
        if(jtfReceber.isSelected()){
            jtfVlRecebido.setEditable(true);
            jtfDataRecebido.setEditable(true);
        }else{
           jtfVlRecebido.setEditable(false);
           jtfDataRecebido.setEditable(false);
        }
}//GEN-LAST:event_jtfReceberActionPerformed

    private void jbBuscaPessoaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscaPessoaActionPerformed
        buscaVer.setTipo("");
        buscaVer bv = new buscaVer(null,true);
        bv.setLocation((index.tela.width-bv.getWidth())/2, (index.tela.height-bv.getHeight())/2);
        bv.setVisible(true);
        if(buscaVer.isConfirmaBusca()){
            cod_pessoa = index.LRpessoa.get(0).toString();
            jtfPessoa.setText(index.LRpessoa.get(1).toString());
        }
    }//GEN-LAST:event_jbBuscaPessoaActionPerformed

    private void jbPlanoContasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbPlanoContasActionPerformed
        buscaPlanoContas bpc = new buscaPlanoContas(null,true);
        bpc.setLocation((index.tela.width-bpc.getWidth())/2, (index.tela.height-bpc.getHeight())/2);
        bpc.setVisible(true);
        if(buscaPlanoContas.isConfirmaContas()){
            cod_plano_contas = index.LRcontas.get(0).toString();
            jtfPlanoContas.setText(index.LRcontas.get(1).toString());
        }
}//GEN-LAST:event_jbPlanoContasActionPerformed

    private void jbCentroCustoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbCentroCustoActionPerformed
        buscaCentroCusto bcc = new buscaCentroCusto(null,true);
        bcc.setLocation((index.tela.width-bcc.getWidth())/2, (index.tela.height-bcc.getHeight())/2);
        bcc.setVisible(true);
        if(buscaCentroCusto.isConfirmaCentro()){
           cod_centro_custo = index.LRcentro.get(0).toString();
           jtfCentroCusto.setText(index.LRcentro.get(1).toString());
        }
}//GEN-LAST:event_jbCentroCustoActionPerformed

    private void jbBuscaTurmaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jbBuscaTurmaActionPerformed
        if(!index.LRpessoa.get(0).toString().equals("")){
            buscaTurma mcbt = new buscaTurma(null, true);
            mcbt.setLocation((index.tela.width-mcbt.getWidth())/2, (index.tela.height-mcbt.getHeight())/2);
            mcbt.setVisible(true);
            if(buscaTurma.isConfirmaTurma()){
                cod_turma = index.LRturma.get(0).toString();
                cod_fase = index.LRfase.get(0).toString();
                jtfTurma.setText(cod_turma+"/"+cod_fase);
            }
        }else{
            JOptionPane.showMessageDialog(null,"Favor selecionar uma Pessoa.","Alerta do Sistema",JOptionPane.ERROR_MESSAGE);
        }
}//GEN-LAST:event_jbBuscaTurmaActionPerformed

    private void formWindowClosed(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosed
        index.LRpessoa.add(0,cod_pessoa);
        index.LRturma.add(0,"");
        index.LRfase.add(0,"");
    }//GEN-LAST:event_formWindowClosed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        String datavenc = jtfDataVenc.getText();
        if(!cod_pessoa.equals("")){
           if(!cod_plano_contas.equals("")){
               if(!cod_centro_custo.equals("")){
                   if(!jtfVlBruto.getText().equals("0,00")&&!jtfVlBruto.getText().equals("0.00")){
                        if(!jtfDataVenc.getText().equals("  /  /    ")){
                            if(jtfReceber.isSelected()){
                                if(!jtfVlRecebido.getText().equals("0,00")&&!jtfVlRecebido.getText().equals("0.00")){
                                    if(!jtfDataRecebido.getText().equals("  /  /    ")){
                                        JOptionPane.showMessageDialog(null, "Em testes");
                                        dispose();
                                    }else{ resposta("Favor digitar uma Data de Pagamento.");jtfDataRecebido.requestFocus();}
                                }else{ resposta("Favor digitar uma Valor Liquído."); jtfVlRecebido.requestFocus();}
                            }else{
                                cod_turma=(cod_turma.equals(""))? "null": "\""+cod_turma+"\"";
                                cod_fase=(cod_fase.equals(""))? "null": "\""+cod_fase+"\"";
                                contadorData.setDataSomaMes(datavenc, "BR");
                                for(int i=Integer.parseInt(jtfParIni.getText()); i<=Integer.parseInt(jtfParcFim.getText());i++){
                                    try {
                                        datavenc = new SimpleDateFormat("yyyy-MM-dd").format(new SimpleDateFormat("dd/MM/yyyy").parse(datavenc));
                                        conexao.Inserir("insert into fin_contas_mov_r(cod_emp,cod_plano_contas,cod_centro_custos,cod_matricula,cod_fase,cod_pessoa,parcela,descricao,dt_emissao,dt_vencimento,valor_bruto,status) " +
                                                " value(" + index.cod_emp + "," + cod_plano_contas + "," + cod_centro_custo + "," + cod_turma + "," + cod_fase + "," + cod_pessoa + "," + i + ",\"" + jtfHistorico.getText() + "\",now(),\"" + datavenc + "\",\""+jtfVlBruto.getText().replace(',','.')+"\",\"A Receber\")");
                                    } catch (ParseException ex) {
                                        verErros.setErro(ex.getMessage());
                                    }
                                    datavenc = contadorData.getDataSomaMes();
                                }
                                JOptionPane.showMessageDialog(null, "Menssalidades geradas.","Confirmação",JOptionPane.INFORMATION_MESSAGE);
                                setConfirmaGerar(true);
                                dispose();
                            }
                        }else{ resposta("Favor digitar uma Data de Vencimento.");jtfDataVenc.requestFocus(); }
                   }else{ resposta("Favor digitar um Valor Bruto.");jtfVlBruto.requestFocus(); }
               }else{ resposta("Favor selecionar um Centro de Custo."); jbCentroCusto.requestFocus();}
           }else{ resposta("Favor selecionar uma Plano de Contas."); jbPlanoContas.requestFocus();}
        }else{ resposta("Favor selecionar uma Pessoa."); jbBuscaPessoa.requestFocus();}
    }//GEN-LAST:event_jButton6ActionPerformed

    private static void resposta(String msn){
        JOptionPane.showMessageDialog(null,msn,"Alerta do Sistema",JOptionPane.ERROR_MESSAGE);
    }

    private void formWindowOpened(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowOpened
        if(!index.LRpessoa.get(0).equals("")){
            try {
                conexao.Query("select codigo, descricao from pessoas where codigo=" + index.LRpessoa.get(0) + " and cod_emp=" + index.cod_emp);
                conexao.rs.next();
                cod_pessoa = conexao.rs.getString("codigo");
                jtfPessoa.setText(conexao.rs.getString("descricao"));
            } catch (SQLException ex) {
                verErros.setErro(ex.getMessage());
            }
        }
        cod_turma="";
        cod_fase="";
        cod_plano_contas="74";
        jtfPlanoContas.setText("Receitas de Menssalidades");
        jtfHistorico.setText("Messalidade");
    }//GEN-LAST:event_formWindowOpened

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JButton jbBuscaPessoa;
    private javax.swing.JButton jbBuscaTurma;
    private javax.swing.JButton jbCentroCusto;
    private javax.swing.JButton jbPlanoContas;
    private javax.swing.JPanel jpCGPrincipal;
    private javax.swing.JTextField jtfCentroCusto;
    private javax.swing.JFormattedTextField jtfDataRecebido;
    private javax.swing.JFormattedTextField jtfDataVenc;
    private javax.swing.JTextField jtfHistorico;
    private javax.swing.JTextField jtfParIni;
    private javax.swing.JTextField jtfParcFim;
    private javax.swing.JTextField jtfPessoa;
    private javax.swing.JTextField jtfPlanoContas;
    private javax.swing.JCheckBox jtfReceber;
    private javax.swing.JTextField jtfTurma;
    private javax.swing.JTextField jtfVlBruto;
    private javax.swing.JTextField jtfVlRecebido;
    // End of variables declaration//GEN-END:variables

}
